/**
 * Created by yuyongzhen <1640599564@qq.com>6.
 */
angular.module('configServices', [])
.service('configService', ['$http', function ($http) {
    return {
        getSourceState:function(type,callback){
          $http({
              method:'GET',
              url:'/stat?type='+type
          }).then(function(response){
              callback.call(this,response.data);
          })
        },
        GetOption: function (platform, x_array, array) {
            var option = {
                title: {
                    text: '抓取历史',
                    subtext: platform
                },
                tooltip: {
                    trigger: 'axis'
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: x_array
                },
                yAxis: {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value}'
                    }
                },
                series: [{
                    name: '时间',
                    type: 'line',
                    data: array,
                    markPoint: {
                        data: [{
                            type: 'max',
                            name: '最大值'
                        }, {
                            type: 'min',
                            name: '最小值'
                        }]
                    },
                    markLine: {
                        data: [{
                            type: 'average',
                            name: '平均值'
                        }]
                    }
                }]
            };
            return option;
        }
    }
}]);
